﻿using NetCore.Extensions;
using System;

namespace NetCore.Services
{
    public static class ServiceConsts
    {

        /// <summary>
        /// 全局静态数据
        /// 工厂需要读取的读配置文件
        /// </summary>
        public static string DesKey = AppSettings("DesKey", "Parakeet.Vip");
        //private IConfiguration _configuration;
        public static readonly string ConnectionString = CustomConfigurationManager.Configuration["ConnectionStrings:default"];
        private static readonly string ModelDll = AppSettings("ModelDll", "ModelDll");
        public static readonly string DllName = ModelDll.Split(',')[0];
        public static readonly string TypeName = ModelDll.Split(',')[1];


        private static T AppSettings<T>(string key, T defaultValue)
        {
            var v = CustomConfigurationManager.Configuration[key];
            //var v = ConfigurationManager.AppSettings[key];
            return v.HasValue() ? (T)Convert.ChangeType(v, typeof(T)) : defaultValue;
        }

    }




}
